package hb.software.message.service.impl;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers;
import org.springframework.stereotype.Service;

import hb.software.message.dao.WorkerMessageDao;
import hb.software.message.domain.WorkerMessage;
import hb.software.service.impl.GenericManagerImpl;
import hb.software.message.service.WorkerMessageManager;


/** 
 * @ClassName: WorkerMessageManagerImpl 
 * @Description: Crud's service of Message module
 * @author YuanMingjie
 * @date May 29, 2020 1:32:35 PM 
 *  
 */
@Service("workerMessageManager")
@Transactional
public class WorkerMessageManagerImpl extends GenericManagerImpl<WorkerMessage, Long> implements WorkerMessageManager {

	WorkerMessageDao workerMessageDao;

	public List<WorkerMessage> findByName(String name) {
		
		WorkerMessage queryObject = new WorkerMessage();
		queryObject.setName(name);
		ExampleMatcher matcher = ExampleMatcher.matching() 
				.withMatcher("name", GenericPropertyMatchers.startsWith()) 
				.withIgnorePaths("dateCreated", "dateModified");
		
		Example<WorkerMessage> ex = Example.of(queryObject, matcher);
		List<WorkerMessage> result = dao.findAll(ex);
		return result;
	}

	@Autowired
	public void setworkerMessageDao(WorkerMessageDao workerMessageDao) {
		this.workerMessageDao = workerMessageDao;
		this.dao = this.workerMessageDao;
	}


}
